package org.baseflexcharts.shapes
{
	import flash.geom.Point;
	
	import mx.core.UIComponent;
	
	public class Sector extends UIComponent
	{
		private var _radius:Number;
		
		private var _startAngle:Number;
		
		private var _angle:Number;
		
		private var _tip:String;
		
		private var _lineColor:uint;
		
		private var _lineWeight:uint;
		
		private var _lineAlpha:Number;
		
		private var _fillColor:uint;
		
		public function Sector(radius:Number, startAngle:Number, angle:Number, tip:String = "", lineColor:uint = 0x000000, fillColor:uint = 0x000000, lineWeight:uint = 1, lineAlpha:Number = 1)
		{
			this.radius = radius;
			this.startAngle = startAngle;
			this.angle = angle;
			this.tip = tip;
			this.lineColor = lineColor;
			this.lineWeight = lineWeight;
			this.lineAlpha = lineAlpha;
			this.fillColor = fillColor;
			draw();
		}
		
		public function draw():void
		{
			this.graphics.clear();
			this.graphics.lineStyle(lineWeight, lineColor, lineAlpha);
			this.graphics.moveTo(0, 0);
			this.graphics.beginFill(fillColor);
			
			for (var i:int = 0; i <= angle; i++) {
			  var degree:Number = Math.PI / 180 * (i + startAngle);
			  var point:Point = Point.polar(radius, degree);
			  this.graphics.lineTo(point.x, point.y);
			}
			
			this.graphics.lineTo(0,0);
			this.graphics.endFill();
			
			this.toolTip = tip;
		}
		
		public function get radius():Number
		{
			return this._radius;
		}
		
		public function set radius(data:Number):void
		{
			this._radius = data;
		}
		
		public function get startAngle():uint
		{
			return this._startAngle;
		}
		
		public function set startAngle(data:uint):void
		{
			this._startAngle = data;
		}
		
		public function get angle():uint
		{
			return this._angle;
		}
		
		public function set angle(data:uint):void
		{
			this._angle = data;
		}
		
		public function get tip():String
		{
			return this._tip;
		}
		
		public function set tip(data:String):void
		{
			this._tip = data;
		}
		
		public function get lineWeight():uint
		{
			return this._lineWeight;
		}
		
		public function set lineWeight(data:uint):void
		{
			this._lineWeight = data;
		}
		
		public function get lineColor():uint
		{
			return this._lineColor;
		}
		
		public function set lineColor(data:uint):void
		{
			this._lineColor = data;
		}
		
		public function get lineAlpha():Number
		{
			return this._lineAlpha;
		}
		
		public function set lineAlpha(data:Number):void
		{
			this._lineAlpha = data;
		}
		
		public function get fillColor():uint
		{
			return this._fillColor;
		}
		
		public function set fillColor(data:uint):void
		{
			this._fillColor = data;
		}
	}
}